Making use of Global Replace
The Replace box works differently to other dialogue boxes: every substitution displaying in the Replace box will be run when Replace or Replace All is clicked. It is not possible to select just one substitution from the list to run. In the following example, even though the Department substitution is highlighted, both substitutions listed will be run:
Tip: Before running a Global Replace, be sure that you have removed substitutions that are no longer required.
Here we step through two useful global replaces:
The Global Replace tool can be used to attach a record to one or more records or replace an existing attachment with another record.
In this example, many parties (recorded in the Parties module) have an association with Party A. The attachment is made using the Party: (Associated With) field:
If the association changes, to Party B for instance, it is a simple matter to search for all affected records and replace the attachment to Party A with an attachment to Party B:
- Search for or retrieve a group of records that need to be changed.
- Select Replace on the Edit tab of the Ribbon.
The Replace box displays with a list of substitutions defined for the current session, if any.
- Click New to define a new substitution. The Substitution box displays:
- From the Field drop list select the field with the attachment to be replaced, e.g. Party: (Associated With).
The field's data type (Integer) automatically displays in the Type field: attachment fields store the IRN (an integer) of the attached record.
- Click Add beside the Text to find field.
The module attached to the field selected at Step 4 displays in Search mode; in this example the Parties module displays and is labelled Parties (2).
- Search for and select the record to be replaced, e.g. the Party A record.
- Click Attach on the Home tab of the Ribbon in the Parties (2) module.
The IRN of the record is copied into the Text to find field. EMu automatically ticks the Regular expression checkbox and places a carrot (^) before and a dollar sign ($) after the IRN.
Note: Entering the text to find between ^ (which indicates the beginning of the field) and $ (which marks the end of the field) indicates that we're looking for (and replacing) the entire contents of the field. See Wildcards in a Global Replace for details.
- In the Substitution box, click Add beside the Replace with field.
The module attached to this field opens; in this example the Parties module displays and is labelled Parties (2).
- Search for and select the replacement record, e.g. the Party B record.
- Click Attach on the Home tab of the Ribbon in the Parties (2) module.
The IRN of the record is copied into the Replace with field:
- Click OK.
The Substitution box closes and the new substitution displays in the Replace box:
- Click Replace All to make the substitution in all records returned / retrieved (at Step 1)
-OR-
Click Replace to make the substitution within the current record or selected records only.
The progress of the replacement displays in a box that includes an option to abort.
When the substitution is complete:
- The Abort button is replaced with an OK button
- The numbers of records processed and modified are displayed.
- Click OK to close the Replace progress box:
The Remove blank rows option is a means to delete rows from multi value fields (such as Other Names: (Person Details) in the Parties module). It is possible:
- To locate and delete empty rows.
-OR-
- Remove a row with a value.
In this simple example, three other names have been recorded for a user, one of which is incorrect and needs to be removed. A row in the Other Names: (Person Details) table contains a value of Y.
and this value (and row) will be removed:
- Search for or retrieve a group of records that need to be changed.
- Select Replace on the Edit tab of the Ribbon.
The Replace box displays with a list of substitutions defined for the current session, if any.
- Click New to display the Substitution box.
- From the Field drop list select the field that contains the value to be removed, Other Names: (Person Details) in this example.
- In the Text to find field enter the text to be replaced surrounded by ^$, i.e. ^Y.$
Entering the text to find between ^ (which indicates the beginning of the field) and $ (which marks the end of the field) indicates that we're looking for the entire contents of the field.
Tip: If you just wanted to search for and remove blank rows, you'd simply enter ^$ in the Text to find field.
- Do not enter anything in the Replace with field.
- Select the checkboxes for:
- Remove blank rows
- Regular expression
- Click OK.
The newly defined substitution is added to the Replace box:
The Options column identifies that two options have been selected: Regular expression (R) and Remove blank rows (B).
Note: If any substitutions are listed that you do not want to run, remove them from the Replace box (select the item and click ) before clicking Replace or Replace All.
- Click Replace to perform the substitution within the current The record currently displayed in Details View or highlighted in List View (there is a faint dotted line around it). It is only possible to have one current record at a time. record or selected A selected record is one that has been chosen either on its own or to as part of a group of records. It is usual to select the records you want to be affected by an operation before performing the operation. Selected records are used in many instances, e.g. when a number of records are to be: discarded, saved in a group, or attached to another record. A selected record displays on screen with a blue background when in List View. records only
-OR-
Click Replace All to perform the substitution in all records currently listed:
The row with the
Y.
value is removed.